package com.xidian.zhiancloud.controller.equipFacility.defendManager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.DefendLedger;
import com.xidian.zhiancloud.model.DefendPlanItem;
import com.xidian.zhiancloud.model.syset.SysUser;
import com.xidian.zhiancloud.qo.equipFacility.DefendLedgerQO;
import com.xidian.zhiancloud.qo.equipFacility.DefendRegisterQO;
import com.xidian.zhiancloud.qo.equipFacility.OhLedgerQO;
import com.xidian.zhiancloud.service.equipFacility.DefendLedgerService;
import com.xidian.zhiancloud.service.equipFacility.DefendPlanItemService;
import com.xidian.zhiancloud.service.equipFacility.DefendRegisterService;
import com.xidian.zhiancloud.service.equipFacility.EqFacMngService;
import com.xidian.zhiancloud.service.user.UserService;
import com.xidian.zhiancloud.vo.equipFacility.DefendLedgerVO;
import com.xidian.zhiancloud.vo.equipFacility.DefendLegerLookVO;
import com.xidian.zhiancloud.vo.equipFacility.DefendPlanItemVO;
import com.xidian.zhiancloud.vo.equipFacility.DefendRegisterVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;

/**
 * 维护台账
 */
@RestController
@RequestMapping("/DefendLedger")
public class DefendLedgerController extends BaseController {

    @Autowired
    private DefendLedgerService defendLedgerService;

    /**
     * 列表查询
     * @param defendRegisterQO 传递参数
     * @return 返回列表
     */
    @GetMapping("/getListByQO")
    public ResultDTO<IPage<DefendRegisterVO>> getListByQO(DefendRegisterQO defendRegisterQO) {
        if (defendRegisterQO.getCurrent() == null || defendRegisterQO.getSize() == null) {
            return ResultDTO.errorOf(GeneralResponseEnums.REQUEST_ERROR);
        }

        defendRegisterQO.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(defendLedgerService.getListByQO(defendRegisterQO), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 查看
     * @param id 台账id
     * @return
     */
    @GetMapping("/getById")
    public ResultDTO<DefendLedgerVO> getById(@RequestParam("id")Long id){
        return ResultDTO.successOf(defendLedgerService.getById(id),GeneralResponseEnums.SUCCESS);
    }
}
